package p.ithorns.integration.transform.entity;

import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableName;
import com.fasterxml.jackson.annotation.JsonFormat;
import io.swagger.annotations.ApiModelProperty;
import lombok.Getter;
import lombok.Setter;
import p.ithorns.integration.transform.enums.Gender;
import p.ithorns.integration.transform.enums.OrderType;
import p.ithorns.tools.translator.annotation.Translatable;
import p.ithorns.tools.translator.annotation.field.ModelField;
import p.ithorns.tools.translator.annotation.meta.EnumDictMeta;
import p.ithorns.tools.translator.annotation.meta.MapDictMeta;

import java.time.LocalDateTime;

/**
 * 实体类对应的数据表为：  order
 *
 * @author ithorns
 * @date 2019-04-22 18:06:24
 */
//@DictGen
@Getter
@Setter
@TableName("`order`")
public class Order {

    @TableId(value = "id", type = IdType.AUTO)
    protected Integer id;

    @ApiModelProperty(value = "类型")
    @TableField(value = "type")
    @EnumDictMeta(enumOf = OrderType.class, label = "typeName")
    protected Integer type;

//    @ApiModelProperty(value = "类型")
//    @TableField(value = "type")
//    @EnumField(from = "type", type = OrderType.class)
//    protected String typeLabel;

    private Integer userId;

    @ApiModelProperty(value = "用户名")
    @TableField(exist = false)
    @ModelField(from = "userId", bean = "userService", prop = "name")
    private String userName;

    @EnumDictMeta(enumOf = Gender.class)
    // @MapDictMeta(mapOf = {"1:男", "2:女"})
    @ModelField(from = "userId", bean = "userService", prop = "gender")
    @TableField(exist = false)
    private String gender;

    @Translatable
    @TableField(exist = false)
    protected OrderDetail detail;

    @Override
    public String toString() {
        return "{" +
                "order:" + id +
                ", userName:'" + userName + '\'' +
                ", detail:" + detail +
                ", type:" + type + //"-" + typeLabel +
                "}";
    }

}